﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sc.Persistence
{
    public class CommDAO
    {
        /// <summary>
        /// 公用分页方法
        /// </summary>
        /// <param name="ht">参数</param>
        /// <returns>DataTable</returns>
        public static Hashtable CommPagination(Hashtable ht)
        {
            Hashtable result = new Hashtable();
            SqlParameter[] param = new SqlParameter[]{
                new SqlParameter("@pageIndex",SqlDbType.VarChar),
                new SqlParameter("@pageSize",SqlDbType.VarChar),
                new SqlParameter("@strSql",SqlDbType.VarChar),
                new SqlParameter("@TableName",SqlDbType.VarChar),
                new SqlParameter("@orderWhere",SqlDbType.VarChar),
                new SqlParameter("@TotalCount",SqlDbType.Int),
                new SqlParameter("@TotalPageCount",SqlDbType.Int)
            };
            param[0].Value = ht["A1"];
            param[1].Value = ht["A2"];
            param[2].Value = ht["A3"];
            param[3].Value = ht["A4"];
            param[4].Value = ht["A5"];
            param[5].Direction = ParameterDirection.Output;
            param[6].Direction = ParameterDirection.Output;
            DataTable dt = DbHelperSQL.Query(CommandType.StoredProcedure, "[Deer_Page]", param);
            result.Add("data", dt); result.Add("record", param[5].Value); result.Add("PageCount", param[6].Value);
            return result;
        }
    }
}
